#required packages
library(lidR)
library(sf)
library(rgl)
## 1 generate synthetic cloud
set.seed(1)
n_pts <- 100000 ## Set the number of points. 1000000 defaul
df <- data.frame(
X = runif(n_pts, 0, 100),
Y = runif(n_pts, 0, 100),
Z = runif(n_pts, 0, 30),
Intensity = sample(1:255, n_pts, TRUE),
ReturnNumber = 1L,
NumberOfReturns = 1L,
Classification = 1L
)
## 2 build LAS & patch header
las <- LAS(df)
las@header@PHB$`File Source ID` <- 1L
las@header@PHB$`Version Major` <- 1L
las@header@PHB$`Version Minor` <- 2L
projection(las) <- 28356 # GDA94 / MGA 56
writeLAS(las, "synth_las.las", index = TRUE)Create LAS Script
About
This script creates a synthetic LAS dataset with an assigned Coordinate Reference System (CRS) for development and testing purposes. This includes what I hope is a compliant header. It draws on R (2025), lidR (Roussel et al. 2020), sf (Pebesma and Bivand 2023) and rgl (Murdoch and Adler 2025) and was created with help from ChatGPT o3. A simple visualisation of the generated dataset is provided.
Copy and run the script below to use. The test las can be found in this repo at [/synth_las.las].
View the test LAS
## 3 save & display (widget auto-prints)
plot3d(las$X, las$Y, las$Z, col = las$Intensity, size = 3)#rglwidget()Download the test LAS
References
Murdoch, Duncan, and Daniel Adler. 2025. “Rgl: 3D Visualization Using OpenGL.” https://doi.org/10.32614/CRAN.package.rgl.
Pebesma, Edzer, and Roger Bivand. 2023. “Spatial Data Science: With Applications in r.” https://doi.org/10.1201/9780429459016.
R Core Team. 2025. “R: A Language and Environment for Statistical Computing.” https://www.R-project.org/.
Roussel, Jean-Romain, David Auty, Nicholas C. Coops, Piotr Tompalski, Tristan R. H. Goodbody, Andrew Sánchez Meador, Jean-François Bourdon, Florian De Boissieu, and Alexis Achim. 2020. “lidR: An R Package for Analysis of Airborne Laser Scanning (ALS) Data.” Remote Sensing of Environment 251 (December): 112061. https://doi.org/10.1016/j.rse.2020.112061.